#include "gtkcellrendererpixbuf.h"
#include "gtkprivate.h"
#include "gtkorientableprivate.h"
+#include "gtkrender.h"
#include <gobject/gmarshal.h>
#include "gtkbuildable.h"
G_OBJECT_CLASS (gtk_cell_view_parent_class)->dispose (object);
}
+static void
+get_padding_and_border (GtkWidget *widget,
+ GtkBorder *border)
+{
+ GtkStyleContext *context;
+ GtkStateFlags state;
+ GtkBorder tmp;
+
+ context = gtk_widget_get_style_context (widget);
+ state = gtk_widget_get_state_flags (widget);
+
+ gtk_style_context_get_padding (context, state, border);
+ gtk_style_context_get_border (context, state, &tmp);
+ border->top += tmp.top;
+ border->right += tmp.right;
+ border->bottom += tmp.bottom;
+ border->left += tmp.left;
+}
+
static void
gtk_cell_view_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkCellView *cellview = GTK_CELL_VIEW (widget);
GtkCellViewPrivate *priv = cellview->priv;
- gint alloc_width, alloc_height;
+ gint alloc_width, alloc_height, width, height;
+ GtkBorder border;
+ get_padding_and_border (widget, &border);
gtk_widget_set_allocation (widget, allocation);
+ width = allocation->width - border.left - border.right;
+ height = allocation->height - border.top - border.bottom;
+
gtk_cell_area_context_get_allocation (priv->context, &alloc_width, &alloc_height);
/* The first cell view in context is responsible for allocating the context at allocate time
* allocate every time.
*/
if (priv->fit_model)
- gtk_cell_area_context_allocate (priv->context, allocation->width, allocation->height);
+ gtk_cell_area_context_allocate (priv->context, width, height);
else if (alloc_width != allocation->width && priv->orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_cell_area_context_allocate (priv->context, allocation->width, -1);
+ gtk_cell_area_context_allocate (priv->context, width, -1);
else if (alloc_height != allocation->height && priv->orientation == GTK_ORIENTATION_VERTICAL)
- gtk_cell_area_context_allocate (priv->context, -1, allocation->height);
+ gtk_cell_area_context_allocate (priv->context, -1, height);
}
static void
{
GtkCellView *cellview = GTK_CELL_VIEW (widget);
GtkCellViewPrivate *priv = cellview->priv;
+ GtkBorder border;
+ get_padding_and_border (widget, &border);
g_signal_handler_block (priv->context, priv->size_changed_id);
if (priv->fit_model)
gtk_cell_area_context_get_preferred_width (priv->context, minimum_size, natural_size);
g_signal_handler_unblock (priv->context, priv->size_changed_id);
+
+ *minimum_size += border.left + border.right;
+ *natural_size += border.left + border.right;
}
static void
{
GtkCellView *cellview = GTK_CELL_VIEW (widget);
GtkCellViewPrivate *priv = cellview->priv;
+ GtkBorder border;
+
+ get_padding_and_border (widget, &border);
g_signal_handler_block (priv->context, priv->size_changed_id);
gtk_cell_area_context_get_preferred_height (priv->context, minimum_size, natural_size);
g_signal_handler_unblock (priv->context, priv->size_changed_id);
+
+ *minimum_size += border.top + border.bottom;
+ *natural_size += border.top + border.bottom;
}
static void
{
GtkCellView *cellview = GTK_CELL_VIEW (widget);
GtkCellViewPrivate *priv = cellview->priv;
+ GtkBorder border;
+
+ get_padding_and_border (widget, &border);
+ for_size -= border.top + border.bottom;
if (priv->fit_model)
{
gtk_cell_area_get_preferred_width_for_height (priv->area, priv->context, widget,
for_size, minimum_size, natural_size);
}
+
+ *minimum_size += border.left + border.right;
+ *natural_size += border.left + border.right;
}
static void
{
GtkCellView *cellview = GTK_CELL_VIEW (widget);
GtkCellViewPrivate *priv = cellview->priv;
+ GtkBorder border;
+
+ get_padding_and_border (widget, &border);
+ for_size -= border.left + border.right;
if (priv->fit_model)
{
gtk_cell_area_get_preferred_height_for_width (priv->area, priv->context, widget,
for_size, minimum_size, natural_size);
}
+
+ *minimum_size += border.top + border.bottom;
+ *natural_size += border.top + border.bottom;
}
static gboolean
GtkCellView *cellview;
GdkRectangle area;
GtkCellRendererState state;
+ GtkBorder border;
+ GtkStyleContext *context;
cellview = GTK_CELL_VIEW (widget);
+ context = gtk_widget_get_style_context (widget);
+
+ get_padding_and_border (widget, &border);
/* render cells */
- area.x = 0;
- area.y = 0;
- area.width = gtk_widget_get_allocated_width (widget);
- area.height = gtk_widget_get_allocated_height (widget);
+ area.x = border.left;
+ area.y = border.top;
+ area.width = gtk_widget_get_allocated_width (widget) - border.left - border.right;
+ area.height = gtk_widget_get_allocated_height (widget) - border.top - border.bottom;
+
+ gtk_render_background (context, cr,
+ 0, 0,
+ gtk_widget_get_allocated_width (widget), gtk_widget_get_allocated_height (widget));
+ gtk_render_frame (context, cr,
+ 0, 0,
+ gtk_widget_get_allocated_width (widget), gtk_widget_get_allocated_height (widget));
/* "blank" background */
if (cellview->priv->background_set)